[receiver/elasticapmintake][processor/elasticapm] Update resource attribute mappings to use semconv to fix aggregated metrics#1069
Conversation
…l semconv Mapping updated for `service.language.name`, `service.language.version`, `service.runtime.name`, and `service.runtime.version`
…r language/runtime attributes Replace legacy service.language.* and service.runtime.* support with semconv equivalents (telemetry.sdk.*, process.runtime.*) in the elasticapmprocessor ECS translation.
…map `host.os.platform` to semconv `os.type` This is required since the `connector/elasticapm` expects the semconv representation
📝 WalkthroughWalkthroughThis pull request removes seven elasticattr constants (HostOSPlatform, ProcessRuntimeName, ProcessRuntimeVersion, ServiceLanguageName, ServiceLanguageVersion, ServiceRuntimeName, ServiceRuntimeVersion) and updates attribute mappings across the processor and receiver components. Service language/runtime attributes are remapped to telemetry.sdk.* and process.runtime.* semantic convention keys, or to labels.* keys in processor output. The host.os.platform attribute is removed entirely. Legacy service language translation logic is deleted, and intake mapper code is refactored to use semantic convention keys directly. Test data files are updated to reflect the new attribute structure and mappings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@receiver/elasticapmintakereceiver/internal/mappers/intakeV2ToSemConv.go`:
- Around line 35-37: This change replaces the original service language fields
with telemetry.sdk.* keys which will be dropped by the current elasticsearch
exporter; revert or guard the change so we do not remove service
language/version until the exporter mapping lands. Specifically, in
intakeV2ToSemConv.go where event.Service.Language is handled (the block that
calls putNonEmptyStr(attributes, string(semconv.TelemetrySDKLanguageKey), ...)
and putNonEmptyStr(...TelemetrySDKVersionKey,...)), either (a) also emit the
original service language keys (preserving service.language/name and
service.language/version) in addition to telemetry.sdk.* or (b) wrap emission of
telemetry.sdk.language and telemetry.sdk.version behind a feature-flag or
conditional that checks the exporter mapping readiness, leaving the existing
service language fields intact; ensure you reference event.Service.Language,
putNonEmptyStr, attributes, semconv.TelemetrySDKLanguageKey and
semconv.TelemetrySDKVersionKey when making the change.
In `@receiver/elasticapmintakereceiver/testdata/logs_expected.yaml`:
- Around line 40-42: Update all occurrences of the os.type field in the test
data from the capitalized "Linux" to the lowercase "linux" to comply with
OpenTelemetry semantic conventions; search for the key "os.type" in
receiver/elasticapmintakereceiver/testdata/logs_expected.yaml and replace any
value stringValue: Linux with stringValue: linux across the file so all OS type
values use the required lowercase set (e.g., linux, darwin, windows, etc.).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f5166557-2495-4332-97df-fc1e50454a43
📒 Files selected for processing (22)
internal/elasticattr/attributes.goprocessor/elasticapmprocessor/internal/ecs/ecs_translation.goprocessor/elasticapmprocessor/internal/ecs/ecs_translation_test.goprocessor/elasticapmprocessor/testdata/ecs/elastic_log/input.yamlprocessor/elasticapmprocessor/testdata/ecs/elastic_log/output.yamlprocessor/elasticapmprocessor/testdata/ecs/elastic_metric/input.yamlprocessor/elasticapmprocessor/testdata/ecs/elastic_metric/output.yamlprocessor/elasticapmprocessor/testdata/ecs/elastic_span_db/input.yamlprocessor/elasticapmprocessor/testdata/ecs/elastic_span_db/output.yamlreceiver/elasticapmintakereceiver/internal/mappers/intakeV2ToDerivedFields.goreceiver/elasticapmintakereceiver/internal/mappers/intakeV2ToElasticSpecificFields.goreceiver/elasticapmintakereceiver/internal/mappers/intakeV2ToSemConv.goreceiver/elasticapmintakereceiver/testdata/errors_expected.yamlreceiver/elasticapmintakereceiver/testdata/hostdata_expected.yamlreceiver/elasticapmintakereceiver/testdata/invalid_ids_expected.yamlreceiver/elasticapmintakereceiver/testdata/language_name_mapping_expected.yamlreceiver/elasticapmintakereceiver/testdata/logs_expected.yamlreceiver/elasticapmintakereceiver/testdata/metricsets_expected.yamlreceiver/elasticapmintakereceiver/testdata/spans_expected.yamlreceiver/elasticapmintakereceiver/testdata/transactions_expected.yamlreceiver/elasticapmintakereceiver/testdata/transactions_spans_expected.yamlreceiver/elasticapmintakereceiver/testdata/unknown-span-type_expected.yaml
💤 Files with no reviewable changes (6)
- receiver/elasticapmintakereceiver/internal/mappers/intakeV2ToElasticSpecificFields.go
- processor/elasticapmprocessor/testdata/ecs/elastic_log/input.yaml
- internal/elasticattr/attributes.go
- receiver/elasticapmintakereceiver/internal/mappers/intakeV2ToDerivedFields.go
- processor/elasticapmprocessor/testdata/ecs/elastic_span_db/input.yaml
- processor/elasticapmprocessor/testdata/ecs/elastic_metric/input.yaml
Previsouly removed with elastic#1069 Signed-off-by: inge4pres <francesco.gualazzi@elastic.co>
…with ECS mapping mode only (#1087) * [processor/elasticapm] Add `host.os.type` enrichment for OTLP events with ECS mapping mode only * prerelease - bump internal/elasticattr version for all modules since we introduced a new const * attributes: remove "host.os.platform" Previsouly removed with #1069 Signed-off-by: inge4pres <francesco.gualazzi@elastic.co> --------- Signed-off-by: inge4pres <francesco.gualazzi@elastic.co> Co-authored-by: Francesco Gualazzi <inge4pres@users.noreply.github.com> Co-authored-by: inge4pres <francesco.gualazzi@elastic.co>
…46900) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description The `host.os.type` enrichment has been moved the [processor/elasticapmprocessor](https://github.com/elastic/opentelemetry-collector-components/tree/main/processor/elasticapmprocessor) for two reasons: 1. The `host.os.type` is only needed for events that are ingested by the OTLP receiver (not APM events ingested by the [receiver/elasticapmintakereciver](https://github.com/elastic/opentelemetry-collector-components/tree/main/receiver/elasticapmintakereceiver)) 2. This type of enrichment should belong to the [processor/elasticapmprocessor](https://github.com/elastic/opentelemetry-collector-components/tree/main/processor/elasticapmprocessor) Related to elastic/opentelemetry-collector-components#1069 and elastic/opentelemetry-collector-components#1087 <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing 1. Updated test cases 2. Removed unnecessary test <!--Describe the documentation added.--> #### Documentation Update `README.md`
Overview
The goal of this PR is to update the intake receiver attribute mappings to use semconv keys to fix missing attributes in aggregate metrics that are generated by the
connector/elasticapm.The
connector/elasticapmincludes resource attributes defined here. These resource attributes use OTel semconv.Receiver Updates
The below table summarizes the new mappings.
Note: The language normalization was removed to closely match the apm-data behavior. So if an apm-events has language "Java" we keep it as is now.
service.language.nametelemetry.sdk.languagec# -> dotnet).service.language.versiontelemetry.sdk.versionservice.runtime.nameprocess.runtime.nameservice.runtime.*to semconv process runtime.service.runtime.versionprocess.runtime.versionservice.runtime.*to semconv process runtime.host.os.platformos.typeProcessor Updates
The
processor/elasticapmwas updated to consider the new semconv fields as supported attributes. The elastic attributes were removed since thereceiver/elasticapmintakewill no longer emit them.Exporter
SemConv mappings
These changes rely on the
exporter/elasticsearchto map thetelemetry.sdk.*attributes back toservice.languagefor the ECS mapping mode: open-telemetry/opentelemetry-collector-contrib#46690. Without the exporter updates thetelemetry.sdk.*attributes will be droppedHost.OS.Type Enrichment in ECS mode
The exporter derives
host.os.typehere usingos.typeandos.name. Since this PR convertshost.os.platformtoos.typethe exporter now has a side effect of adding thehost.os.typeattributes to indexed docs. This field is only needed for otlp events based on the apm-data logic hereSolution:
host.os.typeenrichment to theprocessor/elasticapmhost.os.typeenrichment for events ingested by thereceiver/elasticapmintakePR : [processor/elasticapm] Add
host.os.typeenrichment for OTLP events with ECS mapping mode only #1087host.os.typeenrichment from theexporter/elasticsearchI will follow up with separate PRs for this
Testing
I need to be merged #1067 first since I am having version conflict issues on my local collector. This will allow me to finalize my testing